home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Toolbox
/
Visual Basic Toolbox (P.I.E.)(1996).ISO
/
graphics
/
queen
/
queen.frm
< prev
next >
Wrap
Text File
|
1994-12-23
|
28KB
|
971 lines
VERSION 2.00
Begin Form Form1
BackColor = &H00C0C0C0&
BorderStyle = 3 'Fixed Double
Caption = "Queen's Problem"
ClientHeight = 4020
ClientLeft = 510
ClientTop = 1725
ClientWidth = 2745
Height = 4425
Left = 450
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4020
ScaleWidth = 2745
Top = 1380
Width = 2865
Begin CommandButton Command1
Caption = "Next Solution (Watch Me Work)"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "Arial"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 510
Index = 1
Left = 180
TabIndex = 1
Top = 3330
Width = 2445
End
Begin CommandButton Command1
Caption = "Next Solution"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "Arial"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 510
Index = 0
Left = 180
TabIndex = 0
Top = 2745
Width = 2400
End
Begin Shape col7
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 7
Left = 2295
Shape = 3 'Circle
Top = 135
Visible = 0 'False
Width = 330
End
Begin Shape col6
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 7
Left = 1980
Shape = 3 'Circle
Top = 135
Visible = 0 'False
Width = 330
End
Begin Shape col5
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 7
Left = 1665
Shape = 3 'Circle
Top = 135
Visible = 0 'False
Width = 330
End
Begin Shape col4
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 7
Left = 1350
Shape = 3 'Circle
Top = 135
Visible = 0 'False
Width = 330
End
Begin Shape col3
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 7
Left = 1035
Shape = 3 'Circle
Top = 135
Visible = 0 'False
Width = 330
End
Begin Shape col2
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 7
Left = 720
Shape = 3 'Circle
Top = 135
Visible = 0 'False
Width = 330
End
Begin Shape col1
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 7
Left = 405
Shape = 3 'Circle
Top = 135
Visible = 0 'False
Width = 330
End
Begin Shape col0
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 7
Left = 90
Shape = 3 'Circle
Top = 135
Visible = 0 'False
Width = 330
End
Begin Shape col7
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 6
Left = 2295
Shape = 3 'Circle
Top = 450
Visible = 0 'False
Width = 330
End
Begin Shape col6
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 6
Left = 1980
Shape = 3 'Circle
Top = 450
Visible = 0 'False
Width = 330
End
Begin Shape col5
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 6
Left = 1665
Shape = 3 'Circle
Top = 450
Visible = 0 'False
Width = 330
End
Begin Shape col4
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 6
Left = 1350
Shape = 3 'Circle
Top = 450
Visible = 0 'False
Width = 330
End
Begin Shape col3
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 6
Left = 1035
Shape = 3 'Circle
Top = 450
Visible = 0 'False
Width = 330
End
Begin Shape col2
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 6
Left = 720
Shape = 3 'Circle
Top = 450
Visible = 0 'False
Width = 330
End
Begin Shape col1
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 6
Left = 405
Shape = 3 'Circle
Top = 450
Visible = 0 'False
Width = 330
End
Begin Shape col0
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 6
Left = 90
Shape = 3 'Circle
Top = 450
Visible = 0 'False
Width = 330
End
Begin Shape col7
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 5
Left = 2295
Shape = 3 'Circle
Top = 765
Visible = 0 'False
Width = 330
End
Begin Shape col6
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 5
Left = 1980
Shape = 3 'Circle
Top = 765
Visible = 0 'False
Width = 330
End
Begin Shape col5
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 5
Left = 1665
Shape = 3 'Circle
Top = 765
Visible = 0 'False
Width = 330
End
Begin Shape col4
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 5
Left = 1350
Shape = 3 'Circle
Top = 765
Visible = 0 'False
Width = 330
End
Begin Shape col3
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 5
Left = 1035
Shape = 3 'Circle
Top = 765
Visible = 0 'False
Width = 330
End
Begin Shape col2
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 5
Left = 720
Shape = 3 'Circle
Top = 765
Visible = 0 'False
Width = 330
End
Begin Shape col1
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 5
Left = 405
Shape = 3 'Circle
Top = 765
Visible = 0 'False
Width = 330
End
Begin Shape col0
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 5
Left = 90
Shape = 3 'Circle
Top = 765
Visible = 0 'False
Width = 330
End
Begin Shape col7
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 4
Left = 2295
Shape = 3 'Circle
Top = 1080
Visible = 0 'False
Width = 330
End
Begin Shape col6
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 4
Left = 1980
Shape = 3 'Circle
Top = 1080
Visible = 0 'False
Width = 330
End
Begin Shape col5
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 4
Left = 1665
Shape = 3 'Circle
Top = 1080
Visible = 0 'False
Width = 330
End
Begin Shape col4
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 4
Left = 1350
Shape = 3 'Circle
Top = 1080
Visible = 0 'False
Width = 330
End
Begin Shape col3
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 4
Left = 1035
Shape = 3 'Circle
Top = 1080
Visible = 0 'False
Width = 330
End
Begin Shape col2
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 4
Left = 720
Shape = 3 'Circle
Top = 1080
Visible = 0 'False
Width = 330
End
Begin Shape col1
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 4
Left = 405
Shape = 3 'Circle
Top = 1080
Visible = 0 'False
Width = 330
End
Begin Shape col0
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 4
Left = 90
Shape = 3 'Circle
Top = 1080
Visible = 0 'False
Width = 330
End
Begin Shape col7
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 3
Left = 2295
Shape = 3 'Circle
Top = 1395
Visible = 0 'False
Width = 330
End
Begin Shape col6
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 3
Left = 1980
Shape = 3 'Circle
Top = 1395
Visible = 0 'False
Width = 330
End
Begin Shape col5
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 3
Left = 1665
Shape = 3 'Circle
Top = 1395
Visible = 0 'False
Width = 330
End
Begin Shape col4
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 3
Left = 1350
Shape = 3 'Circle
Top = 1395
Visible = 0 'False
Width = 330
End
Begin Shape col3
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 3
Left = 1035
Shape = 3 'Circle
Top = 1395
Visible = 0 'False
Width = 330
End
Begin Shape col2
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 3
Left = 720
Shape = 3 'Circle
Top = 1395
Visible = 0 'False
Width = 330
End
Begin Shape col1
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 3
Left = 405
Shape = 3 'Circle
Top = 1395
Visible = 0 'False
Width = 330
End
Begin Shape col0
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 3
Left = 90
Shape = 3 'Circle
Top = 1395
Visible = 0 'False
Width = 330
End
Begin Shape col7
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 2
Left = 2295
Shape = 3 'Circle
Top = 1710
Visible = 0 'False
Width = 330
End
Begin Shape col6
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 2
Left = 1980
Shape = 3 'Circle
Top = 1710
Visible = 0 'False
Width = 330
End
Begin Shape col5
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 2
Left = 1665
Shape = 3 'Circle
Top = 1710
Visible = 0 'False
Width = 330
End
Begin Shape col4
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 2
Left = 1350
Shape = 3 'Circle
Top = 1710
Visible = 0 'False
Width = 330
End
Begin Shape col3
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 2
Left = 1035
Shape = 3 'Circle
Top = 1710
Visible = 0 'False
Width = 330
End
Begin Shape col2
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 2
Left = 720
Shape = 3 'Circle
Top = 1710
Visible = 0 'False
Width = 330
End
Begin Shape col1
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 2
Left = 405
Shape = 3 'Circle
Top = 1710
Visible = 0 'False
Width = 330
End
Begin Shape col0
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 2
Left = 90
Shape = 3 'Circle
Top = 1710
Visible = 0 'False
Width = 330
End
Begin Shape col7
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 1
Left = 2295
Shape = 3 'Circle
Top = 2025
Visible = 0 'False
Width = 330
End
Begin Shape col6
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 1
Left = 1980
Shape = 3 'Circle
Top = 2025
Visible = 0 'False
Width = 330
End
Begin Shape col5
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 1
Left = 1665
Shape = 3 'Circle
Top = 2025
Visible = 0 'False
Width = 330
End
Begin Shape col4
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 1
Left = 1350
Shape = 3 'Circle
Top = 2025
Visible = 0 'False
Width = 330
End
Begin Shape col3
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 1
Left = 1035
Shape = 3 'Circle
Top = 2025
Visible = 0 'False
Width = 330
End
Begin Shape col2
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 1
Left = 720
Shape = 3 'Circle
Top = 2025
Visible = 0 'False
Width = 330
End
Begin Shape col1
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 1
Left = 405
Shape = 3 'Circle
Top = 2025
Visible = 0 'False
Width = 330
End
Begin Shape col0
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 1
Left = 90
Shape = 3 'Circle
Top = 2025
Visible = 0 'False
Width = 330
End
Begin Shape col7
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 0
Left = 2295
Shape = 3 'Circle
Top = 2340
Visible = 0 'False
Width = 330
End
Begin Shape col6
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 0
Left = 1980
Shape = 3 'Circle
Top = 2340
Visible = 0 'False
Width = 330
End
Begin Shape col5
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 0
Left = 1665
Shape = 3 'Circle
Top = 2340
Visible = 0 'False
Width = 330
End
Begin Shape col4
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 0
Left = 1350
Shape = 3 'Circle
Top = 2340
Visible = 0 'False
Width = 330
End
Begin Shape col3
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 0
Left = 1035
Shape = 3 'Circle
Top = 2340
Visible = 0 'False
Width = 330
End
Begin Shape col2
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 0
Left = 720
Shape = 3 'Circle
Top = 2340
Visible = 0 'False
Width = 330
End
Begin Shape col1
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 0
Left = 405
Shape = 3 'Circle
Top = 2340
Visible = 0 'False
Width = 330
End
Begin Shape col0
FillColor = &H00FFFF00&
FillStyle = 0 'Solid
Height = 330
Index = 0
Left = 90
Shape = 3 'Circle
Top = 2340
Visible = 0 'False
Width = 330
End
Begin Line Line2
Index = 7
X1 = 90
X2 = 2610
Y1 = 765
Y2 = 765
End
Begin Line Line2
Index = 6
X1 = 90
X2 = 2610
Y1 = 1080
Y2 = 1080
End
Begin Line Line2
Index = 5
X1 = 90
X2 = 2610
Y1 = 1395
Y2 = 1395
End
Begin Line Line2
Index = 4
X1 = 90
X2 = 2610
Y1 = 1710
Y2 = 1710
End
Begin Line Line2
Index = 3
X1 = 90
X2 = 2610
Y1 = 2025
Y2 = 2025
End
Begin Line Line2
Index = 2
X1 = 90
X2 = 2610
Y1 = 2340
Y2 = 2340
End
Begin Line Line2
Index = 0
X1 = 90
X2 = 2610
Y1 = 450
Y2 = 450
End
Begin Line Line1
Index = 6
X1 = 2295
X2 = 2295
Y1 = 2655
Y2 = 135
End
Begin Line Line1
Index = 5
X1 = 720
X2 = 720
Y1 = 2655
Y2 = 135
End
Begin Line Line1
Index = 4
X1 = 1035
X2 = 1035
Y1 = 2655
Y2 = 135
End
Begin Line Line1
Index = 3
X1 = 1350
X2 = 1350
Y1 = 2655
Y2 = 135
End
Begin Line Line1
Index = 2
X1 = 1665
X2 = 1665
Y1 = 2655
Y2 = 135
End
Begin Line Line1
Index = 1
X1 = 1980
X2 = 1980
Y1 = 2655
Y2 = 135
End
Begin Line Line1
Index = 0
X1 = 405
X2 = 405
Y1 = 2655
Y2 = 135
End
Begin Shape Shape1
Height = 2535
Left = 90
Top = 135
Width = 2535
End
End
Option Explicit
Dim fgBoard(0 To 7) As Integer
Dim fgCurrentCol As Integer
Dim fgWorking As Integer
Dim fgwatch As Integer
Sub backup ()
fgBoard(fgCurrentCol) = -1
fgCurrentCol = fgCurrentCol - 1
If fgCurrentCol = -1 Then
End
End If
fgBoard(fgCurrentCol) = fgBoard(fgCurrentCol) + 1
If fgBoard(fgCurrentCol) > 7 Then
backup
End If
End Sub
Function CheckPosition () As Integer
Dim NoHits As Integer
Dim lCol As Integer
NoHits = -1
For lCol = fgCurrentCol - 1 To 0 Step -1
If (fgBoard(fgCurrentCol) = fgBoard(lCol)) Or (Abs((fgBoard(fgCurrentCol) - fgBoard(lCol)) / (fgCurrentCol - lCol)) = 1) Then
NoHits = 0
Exit For
End If
Next lCol
CheckPosition = NoHits
End Function
Sub Command1_Click (index As Integer)
fgwatch = index
NextSolution
End Sub
Sub DrawBoard ()
Dim lShape As Shape
Dim lCol As Integer
Dim lRow As Integer
For lCol = 0 To 7
For lRow = 0 To 7
Select Case lCol
Case 0
Set lShape = col0(lRow)
Case 1
Set lShape = col1(lRow)
Case 2
Set lShape = col2(lRow)
Case 3
Set lShape = col3(lRow)
Case 4
Set lShape = col4(lRow)
Case 5
Set lShape = col5(lRow)
Case 6
Set lShape = col6(lRow)
Case 7
Set lShape = col7(lRow)
End Select
lShape.Visible = (lRow = fgBoard(lCol))
Next lRow
Next lCol
DoEvents
End Sub
Sub Form_Load ()
Dim i As Integer
For i = 0 To 7
fgBoard(i) = -1
Next
fgCurrentCol = 0
'For i = 0 To 7
' fgBoard(i) = i
'Next
'DrawBoard
End Sub
Sub NextSolution ()
Dim lCol As Integer
Dim NoHits As Integer
If fgWorking Then
Exit Sub
End If
fgWorking = -1
fgBoard(fgCurrentCol) = fgBoard(fgCurrentCol) + 1
Do While True
If CheckPosition() Then
fgCurrentCol = fgCurrentCol + 1
If fgCurrentCol > 7 Then
Exit Do
End If
fgBoard(fgCurrentCol) = 0
Else
If fgBoard(fgCurrentCol) >= 7 Then
backup
Else
fgBoard(fgCurrentCol) = fgBoard(fgCurrentCol) + 1
End If
End If
If fgwatch Then
DrawBoard
End If
Loop
DrawBoard
fgCurrentCol = 7
fgWorking = 0
End Sub